package array;

/**
 * @Author Klys
 * @Date 2023/4/7 17:01
 * @Description
 * @Version 1.0
 */

/**
 * clone实现深拷贝
 */

public class Demo01 {
    public static void main(String[] args) {
        // 定义原数组，长度为8
        int scores[] = new int[]{100, 81, 68, 75, 91, 66, 75, 100};
        for (int i = 0; i < scores.length; i++) {
            System.out.print(scores[i] + "\t");
        }
        // 复制数组，将Object类型强制转换为int[]类型
        int newScores[] = (int[]) scores.clone();
        // 循环遍历目标数组
        for (int k = 0; k < newScores.length; k++) {
            System.out.print(newScores[k] + "\t");
        }

        System.out.println("scores的hashcode：" + scores.hashCode());
        System.out.println("newScores的hashcode：" + newScores.hashCode());
        System.out.println(scores == newScores);

        scores[0] = 1;
        System.out.println(newScores[0] + scores[0]);
    }
}
